package com.system.demo.controller.comments;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.system.demo.entity.comment.CommentSearchDTO;
import com.system.demo.entity.comment.ReplyDTO;
import com.system.demo.service.comment.CommentService;
import com.system.demo.tool.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment/admin")
@SaCheckRole("ROLE_ADMIN")
public class CommentAdminController {
    @Autowired
    private CommentService commentService;

    //删除留言 or 评论  留言type为0 评论type为1
    @DeleteMapping
    public ResponseResult<?> deleteComments( @RequestParam Integer type, @RequestParam Integer id){
        return commentService.deleteCommentsByAdmin(type, id);
    }

    //查看给管理员的留言(未回复0 已回复1)
    @GetMapping
    public ResponseResult<?> getPrivateMessage(@RequestParam Integer isCheck, @RequestParam Integer current, @RequestParam Integer size){
        return commentService.getPrivateMessage(isCheck, current, size);
    }

    //对系统留言进行回复
    //如果管理员对公共频道的留言进行回复 那么调用普通端的接口就行
    @PostMapping("/reply")
    public ResponseResult<?> addReplyByAdmin(@RequestBody ReplyDTO replyDTO){
        return commentService.addReplyByAdmin(replyDTO);
    }

}
